Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix Windows: Remove lmdb files when delete_library is called #1437

Merged
merged 3 commits into from
Mar 20, 2024

Conversation

muhammadhamzasajjad
Copy link
Collaborator

@muhammadhamzasajjad muhammadhamzasajjad commented Mar 18, 2024

Reference Issues/PRs

Fixes #1266. The cause of this error was that LmdbStorage member env_ keeps a handle open to the files and windows doesn't delete files if they have been opened by another process. The previous fix was attempting to do del lib in python and assuming that this would automatically call the LmdbStorage destructor and remove the env_ handle. del lib doesn't guarantee immediate deletion of the library. Therefore on windows delete_library doesn't work as other lmdb has opened the files.

What does this implement or fix?

The fix moves the file removal logic in LmdbStorage by adding a new function close. The lmdb env handle is closed and this ensures no process has opened the lmdb files, so they are safe to delete.

Any other comments?

Checklist

Checklist for code changes...
  • Have you updated the relevant docstrings, documentation and copyright notice?
  • Is this contribution tested against all ArcticDB's features?
  • Do all exceptions introduced raise appropriate error messages?
  • Are API changes highlighted in the PR description?
  • Is the PR labelled as enhancement or bug so it appears in autogenerated release notes?

@muhammadhamzasajjad muhammadhamzasajjad self-assigned this Mar 18, 2024
@muhammadhamzasajjad muhammadhamzasajjad added the bug Something isn't working label Mar 18, 2024
@muhammadhamzasajjad muhammadhamzasajjad marked this pull request as ready for review March 19, 2024 12:04
cpp/arcticdb/storage/lmdb/lmdb_storage.hpp Outdated Show resolved Hide resolved
cpp/arcticdb/storage/test/test_storage_exceptions.cpp Outdated Show resolved Hide resolved
python/arcticdb/adapters/lmdb_library_adapter.py Outdated Show resolved Hide resolved
cpp/arcticdb/storage/library_manager.cpp Outdated Show resolved Hide resolved
@poodlewars
Copy link
Collaborator

Have you done a bit of manual testing? Can we still create an lmdb library, closed the python interpreter and have that library still readable? Want to be sure we aren't deleting anything inadvertently. Our CI tests probably wouldn't catch it as they all deliberately delete the LMDB database at the end anyway!

@muhammadhamzasajjad
Copy link
Collaborator Author

muhammadhamzasajjad commented Mar 19, 2024

Have you done a bit of manual testing? Can we still create an lmdb library, closed the python interpreter and have that library still readable?

Yes, I have tested that and lmdb library isn't unexpectedly deleted if we close the interpreter.

@muhammadhamzasajjad muhammadhamzasajjad merged commit 7d57f21 into master Mar 20, 2024
113 of 114 checks passed
@muhammadhamzasajjad muhammadhamzasajjad deleted the delete_library_windows branch March 20, 2024 00:07
grusev pushed a commit that referenced this pull request Nov 25, 2024
…1437)

#### Reference Issues/PRs
Fixes #1266. The cause of this error was that `LmdbStorage` member
`env_` keeps a handle open to the files and windows doesn't delete files
if they have been opened by another process. The previous fix was
attempting to do `del lib` in python and assuming that this would
automatically call the `LmdbStorage` destructor and remove the `env_`
handle. `del lib` doesn't guarantee immediate deletion of the library.
Therefore on windows delete_library doesn't work as other lmdb has
opened the files.

#### What does this implement or fix?
The fix moves the file removal logic in `LmdbStorage` by adding a new
function `close`. The lmdb env handle is closed and this ensures no
process has opened the lmdb files, so they are safe to delete.

#### Any other comments?

#### Checklist

<details>
  <summary>
   Checklist for code changes...
  </summary>
 
- [ ] Have you updated the relevant docstrings, documentation and
copyright notice?
- [ ] Is this contribution tested against [all ArcticDB's
features](../docs/mkdocs/docs/technical/contributing.md)?
- [ ] Do all exceptions introduced raise appropriate [error
messages](https://docs.arcticdb.io/error_messages/)?
 - [ ] Are API changes highlighted in the PR description?
- [x] Is the PR labelled as enhancement or bug so it appears in
autogenerated release notes?
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

delete_library does not delete the data file in the folder
2 participants